//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ruoyi.web.controller.platform;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.live.base.domain.SystemClassUserImport;
import com.ruoyi.live.platform.service.SystemClassUserImportService;
import com.ruoyi.live.tool.utils.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import jakarta.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping({"/system"})
public class SystemClassUserImportController extends BaseController {
    @Autowired
    SystemClassUserImportService service;

    public SystemClassUserImportController() {
    }

    @ResponseBody
    @RequestMapping({"/SystemClassUserImportController/queryList"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public List<SystemClassUserImport> queryList(Long id) {
        return this.service.queryList(id);
    }

    @RequestMapping({"/SystemClassUserImportController/index"})
    public String index() {
        return "platform/system_class_user_import_list";
    }

    @ResponseBody
    @RequestMapping({"/SystemClassUserImportController/query"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public TableDataInfo query(SystemClassUserImport entity) {
        this.startPage();
        List<SystemClassUserImport> list = this.service.query(entity);
        return this.getDataTable(list);
    }

    @ResponseBody
    @RequestMapping({"/SystemClassUserImportController/add"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message add(SystemClassUserImport entity, MultipartFile file, HttpServletRequest request) {
        try {
            this.service.addSystemClassUserImport(entity, file, request);
            return new Message(true, "新增成功");
        } catch (Exception var5) {
            var5.printStackTrace();
            return new Message(false, var5.getMessage());
        }
    }

    @ResponseBody
    @RequestMapping({"/SystemClassUserImportController/update"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message update(SystemClassUserImport entity) {
        try {
            this.service.updateSystemClassUserImport(entity);
            return new Message(true, "修改成功");
        } catch (Exception var3) {
            var3.printStackTrace();
            return new Message(false, var3.getMessage());
        }
    }

    @ResponseBody
    @RequestMapping({"/SystemClassUserImportController/delete"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message delete(String id) {
        try {
            this.service.deleteSystemClassUserImport(id.split(","));
            return new Message(true, "删除成功");
        } catch (Exception var3) {
            var3.printStackTrace();
            return new Message(false, var3.getMessage());
        }
    }

    @RequestMapping({"/SystemClassUserImportController/view"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public ModelAndView view(Long id, String page) {
        ModelAndView mv = new ModelAndView("platform/" + page);
        if (id != null) {
            try {
                mv.addObject("entity", this.service.getSystemClassUserImport(id));
            } catch (Exception var5) {
                return (new ModelAndView("error")).addObject("tip", var5.getMessage());
            }
        }

        return mv;
    }

    @ResponseBody
    @RequestMapping({"/SystemClassUserImportController/importSingle"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message importSingle(Long id) {
        try {
            this.service.doReImport(id);
            return new Message(true, "导入成功");
        } catch (Exception var3) {
            var3.printStackTrace();
            return new Message(false, var3.getMessage());
        }
    }

    @ResponseBody
    @RequestMapping({"/SystemClassUserImportController/importAll"})
    @PreAuthorize("@ss.hasAnyRoles('admin')")
    public Message importAll(Long id) {
        try {
            this.service.importAll(id);
            return new Message(true, "导入成功");
        } catch (Exception var3) {
            var3.printStackTrace();
            return new Message(false, "导入失败");
        }
    }
}
